package models

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var DB *gorm.DB
var err error

func Init() {
	Dsn := "root:89B158B4DAFE6F5461878D26EA49B100@tcp(14.103.158.217:3306)/goods?charset=utf8&parseTime=True&loc=Local"
	DB, err = gorm.Open(mysql.Open(Dsn))
	if err != nil {
		fmt.Println("数据库连接失败")
		return
	}
	err = DB.AutoMigrate(&Good{})
	if err != nil {
		fmt.Println("数据表迁移失败")
		return
	}
	fmt.Println("预处理完成")
}
